//
//  MQLeadListViewModel.swift
//  leadpagemoudle
//
//  Created by 许博 on 2017/4/17.
//  Copyright © 2017年 mechat. All rights reserved.
//

import UIKit



class MQLeadListViewModel: NSObject {
    
    var dateString:String? // 处理好的日期
    
    var listModel:MQLeadListModel?
    init(model:MQLeadListModel) {
        
        self.listModel = model
        
        // 2017-04-26T12:13:51Z  -to- 04-26 12:13
        let dateStr = model.LastViewedDate
        guard let dateSourse = dateStr else {
            return
        }
        let string = dateSourse as NSString
        
        self.dateString = MQLeadListViewModel.dealString(string: string)
        
    }
    
    private class func dealString(string:NSString)->(String){
        let tRange = string.range(of: "T")
        
        let dateString = string.substring(to: tRange.location) as NSString
        let firstSep = dateString.range(of: "-")
        let dd = dateString.substring(from: firstSep.location + 1)
        
        let timeString = string.substring(from: tRange.location + 1) as NSString
        let time = timeString.substring(to: timeString.length - 4)
        
        return dd.appending(" "+"\(time)")
    }
    
    
}
